package com.samsung.dementia.protocol;

import net.sf.json.JSONObject;

public class CommandDecoder {

	public JSONObject decode(JSONObject jsonObject) {

		String command = jsonObject.getString("command");

		JSONObject ret = null;

		if (command.equalsIgnoreCase(Command.COMMAND_DEMENTIA_QUESTIONNAIRE_DATA)) {
			ret = CommandProcessor.insertDailyDQData(jsonObject);
		} else if (command.equalsIgnoreCase(Command.COMMAND_LOGIN)) {
			ret = CommandProcessor.compareLoginInfoAndupdateTimestamp(jsonObject);
		} else if (command.equalsIgnoreCase(Command.COMMAND_CHECK_SERVER_STATUS)) {
			ret = CommandProcessor.checkServerAlive(jsonObject);
		} else if (command.equalsIgnoreCase(Command.COMMAND_LOCATION_DATA)) {
			ret = CommandProcessor.insertDailyLocationData(jsonObject);
		} else if (command.equalsIgnoreCase(Command.COMMAND_HUMAN_MOVEMENT_RECOGNITION_DATA)) {
			ret = CommandProcessor.insertHumanMovmentRecognitionData(jsonObject);
		} else if (command.equalsIgnoreCase(Command.COMMAND_APP_INFO)) {
			ret = CommandProcessor.insertAppInfo(jsonObject);
		} else if (command.equalsIgnoreCase(Command.COMMAND_SOCIAL_DATA)) {
			ret = CommandProcessor.insertSocialData(jsonObject);
		}

		return ret;
	}
}
